package TCP;

import java.io.OutputStream;
import java.net.Socket;
import java.util.Scanner;

public class Client {
    public static void main(String[] args) throws Exception {
        //链接到服务器
        Socket socket = new Socket("127.0.0.1", 8888);
        //发消息
        OutputStream os = socket.getOutputStream();
        Scanner input = new Scanner(System.in);
        while (true) {
            String str = input.nextLine();
            os.write(str.getBytes());
            System.out.println("消息发送成功");
            if(str.equals("n")){
                socket.shutdownOutput();
                break;
            }
        }


       /* os.close();
        socket.close();*/

    }
}
